Rendering based on a document object model

ABSTRACT

Methods and systems for rendering content are described herein. In some embodiments, the method may include receiving an email or other markup language based content. The method may create a document object model (DOM) corresponding to the content using an off screen browser. The method may cause the off screen browser to indicate that the DOM has been created before the off screen browser retrieves any external content. The method may extract a portion of the content from the DOM, and then render the portion of the content using predefined formatting rules.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims priority to provisional patent application62/158,695, filed May 8, 2015, and entitle “Email Rendering Based on aDocument Object Model,” herein incorporated by reference in its entiretyfor all purposes.

FIELD

Aspects described herein generally relate to rendering content fordisplay by a computing device. More specifically, aspects describedherein relate to pre-generating a Document Object Model (DOM) forcontent to expedite the rendering process.

BACKGROUND

An email or portions of an email may be received in a HyperText MarkupLanguage (HTML) format. Conventional systems, when rendering the email,render portions twice. The email may first be rendered with styles orscripts that are included in the HTML email. When rendering the email,external content such as images may be downloaded. After retrieving allthe content and rendering the email once, the system may apply a customstyle or script to the HTML email, and the email may be rendered asecond time with the system's desired formatting. The external contentmay be downloaded a second time as well. Rendering twice and downloadingexternal content twice is inefficient. Further, displaying the emailboth times that it is rendered may present a flickering effect orchanging the display to a user. Similar problems are encountered withnon-email content as well.

SUMMARY

The following presents a simplified summary of various aspects describedherein. This summary is not an extensive overview, and is not intendedto identify key or critical elements or to delineate the scope of theclaims. The following summary merely presents some concepts in asimplified form as an introductory prelude to the more detaileddescription provided below.

To overcome limitations in the prior art described above, and toovercome other limitations that will be apparent upon reading andunderstanding the present specification, aspects described herein aredirected towards rendering content using a document object model.

Aspects of the disclosure relate to various techniques and technologiesfor a method for rendering content for display. In one implementation,the method may include receiving HTML-based content. The method maycreate a document object model (DOM) corresponding to the content usingan off screen browser. The method may cause the off screen browser toindicate that the DOM has been created before the off screen browserretrieves any external content. The method may extract a portion of thecontent from the DOM, and render the portion of the content usingpredefined formatting rules.

Aspects of the disclosure also relate to various techniques andtechnologies for a method for rendering an email. In one implementation,the method may include adding a script to an email. The script isconfigured to prevent a web browser from retrieving external contentlinked within the email. The method may load the email using the webbrowser to generate a DOM corresponding to the email. The method mayalso render the email based on the DOM.

Aspects of the disclosure also relate to various techniques andtechnologies for a method for rendering a document having markuplanguage content. The method may include invoking a first web browser togenerate a DOM based on the markup language content. The generating isperformed without downloading external content by the first web browser.The method may extract style-neutral content from the DOM. The methodmay apply a style to the style-neutral content. The method may alsorender the style-neutral content based on the applied style using asecond web browser.

These and additional aspects will be appreciated with the benefit of thedisclosures discussed in further detail below.

BRIEF DESCRIPTION OF THE DRAWINGS

A more complete understanding of aspects described herein and theadvantages thereof may be acquired by referring to the followingdescription in consideration of the accompanying drawings, in which likereference numbers indicate like features, and wherein:

FIG. 1 depicts an illustrative computer system architecture that may beused in accordance with one or more illustrative aspects describedherein.

FIG. 2 depicts an illustrative remote-access system architecture thatmay be used in accordance with one or more illustrative aspectsdescribed herein.

FIG. 3 illustrates a method and data flow for generating a DocumentObject Model (DOM) and loading external content according to one or moreillustrative aspects described herein.

FIG. 4 illustrates a method and data flow for displaying a Hyper TextMarkup Language (HTML) email according to one or more illustrativeaspects described herein.

FIG. 5 illustrates a method and data flow for creating a DOM accordingto one or more illustrative aspects described herein.

FIG. 6 depicts examples of HTML and a corresponding DOM according to oneor more illustrative aspects described herein.

FIG. 7 illustrates an example of a script that may stop pending networkrequests according to one or more illustrative aspects described herein.

FIG. 8 illustrates an example of a script that may issue a detectableerror code according to one or more illustrative aspects describedherein.

DETAILED DESCRIPTION

In the following description of the various embodiments, reference ismade to the accompanying drawings identified above and which form a parthereof, and in which is shown by way of illustration various embodimentsin which aspects described herein may be practiced. It is to beunderstood that other embodiments may be utilized and structural andfunctional modifications may be made without departing from the scopedescribed herein. Various aspects are capable of other embodiments andof being practiced or being carried out in various different ways.

It is to be understood that the phraseology and terminology used hereinare for the purpose of description and should not be regarded aslimiting. Rather, the phrases and terms used herein are to be giventheir broadest interpretation and meaning. The use of “including” and“comprising” and variations thereof is meant to encompass the itemslisted thereafter and equivalents thereof as well as additional itemsand equivalents thereof. The use of the terms “mounted,” “connected,”“coupled,” “positioned,” “engaged” and similar terms, is meant toinclude both direct and indirect mounting, connecting, coupling,positioning and engaging.

Computing Architecture

Computer software, hardware, and networks may be utilized in a varietyof different system environments, including standalone, networked,remote-access (aka, remote desktop), virtualized, and/or cloud-basedenvironments, among others. FIG. 1 illustrates one example of a systemarchitecture and data processing device that may be used to implementone or more illustrative aspects described herein in a standalone and/ornetworked environment. Various network nodes 103, 105, 107, and 109 maybe interconnected via a wide area network (WAN) 101, such as theInternet. Other networks may also or alternatively be used, includingprivate intranets, corporate networks, LANs, metropolitan area networks(MAN) wireless networks, personal networks (PAN), and the like. Network101 is for illustration purposes and may be replaced with fewer oradditional computer networks. A local area network (LAN) may have one ormore of any known LAN topology and may use one or more of a variety ofdifferent protocols, such as Ethernet. Devices 103, 105, 107, 109 andother devices (not shown) may be connected to one or more of thenetworks via twisted pair wires, coaxial cable, fiber optics, radiowaves or other communication media.

The term “network” as used herein and depicted in the drawings refersnot only to systems in which remote storage devices are coupled togethervia one or more communication paths, but also to stand-alone devicesthat may be coupled, from time to time, to such systems that havestorage capability. Consequently, the term “network” includes not only a“physical network” but also a “content network,” which is comprised ofthe data—attributable to a single entity—which resides across allphysical networks.

The components may include data server 103, web server 105, and clientcomputers 107, 109. Data server 103 provides overall access, control andadministration of databases and control software for performing one ormore illustrative aspects describe herein. Data server 103 may beconnected to web server 105 through which users interact with and obtaindata as requested. Alternatively, data server 103 may act as a webserver itself and be directly connected to the Internet. Data server 103may be connected to web server 105 through the network 101 (e.g., theInternet), via direct or indirect connection, or via some other network.Users may interact with the data server 103 using remote computers 107,109, e.g., using a web browser to connect to the data server 103 via oneor more externally exposed web sites hosted by web server 105. Clientcomputers 107, 109 may be used in concert with data server 103 to accessdata stored therein, or may be used for other purposes. For example,from client device 107 a user may access web server 105 using anInternet browser, as is known in the art, or by executing a softwareapplication that communicates with web server 105 and/or data server 103over a computer network (such as the Internet).

Servers and applications may be combined on the same physical machines,and retain separate virtual or logical addresses, or may reside onseparate physical machines. FIG. 1 illustrates just one example of anetwork architecture that may be used, and those of skill in the artwill appreciate that the specific network architecture and dataprocessing devices used may vary, and are secondary to the functionalitythat they provide, as further described herein. For example, servicesprovided by web server 105 and data server 103 may be combined on asingle server.

Each component 103, 105, 107, 109 may be any type of known computer,server, or data processing device. Data server 103, e.g., may include aprocessor 111 controlling overall operation of the rate server 103. Dataserver 103 may further include random access memory (RAM) 113, read onlymemory (ROM) 115, network interface 117, input/output interfaces 119(e.g., keyboard, mouse, display, printer, etc.), and memory 121.Input/output (I/O) 119 may include a variety of interface units anddrives for reading, writing, displaying, and/or printing data or files.Memory 121 may further store operating system software 123 forcontrolling overall operation of the data processing device 103, controllogic 125 for instructing data server 103 to perform aspects describedherein, and other application software 127 providing secondary, support,and/or other functionality which may or might not be used in conjunctionwith aspects described herein. The control logic may also be referred toherein as the data server software 125. Functionality of the data serversoftware may refer to operations or decisions made automatically basedon rules coded into the control logic, made manually by a user providinginput into the system, and/or a combination of automatic processingbased on user input (e.g., queries, data updates, etc.).

Memory 121 may also store data used in performance of one or moreaspects described herein, including a first database 129 and a seconddatabase 131. In some embodiments, the first database may include thesecond database (e.g., as a separate table, report, etc.). That is, theinformation can be stored in a single database, or separated intodifferent logical, virtual, or physical databases, depending on systemdesign. Devices 105, 107, 109 may have similar or different architectureas described with respect to device 103. Those of skill in the art willappreciate that the functionality of data processing device 103 (ordevice 105, 107, 109) as described herein may be spread across multipledata processing devices, for example, to distribute processing loadacross multiple computers, to segregate transactions based on geographiclocation, user access level, quality of service (QoS), etc.

One or more aspects may be embodied in computer-usable or readable dataand/or computer-executable instructions, such as in one or more programmodules, executed by one or more computers or other devices as describedherein. Generally, program modules include routines, programs, objects,components, data structures, etc. that perform particular tasks orimplement particular abstract data types when executed by a processor ina computer or other device. The modules may be written in a source codeprogramming language that is subsequently compiled for execution, or maybe written in a scripting language such as (but not limited to)HyperText Markup Language (HTML) or Extensible Markup Language (XML).The computer executable instructions may be stored on a computerreadable medium such as a nonvolatile storage device. Any suitablecomputer readable storage media may be utilized, including hard disks,CD-ROMs, optical storage devices, magnetic storage devices, and/or anycombination thereof. In addition, various transmission (non-storage)media representing data or events as described herein may be transferredbetween a source and a destination in the form of electromagnetic wavestraveling through signal-conducting media such as metal wires, opticalfibers, and/or wireless transmission media (e.g., air and/or space).Various aspects described herein may be embodied as a method, a dataprocessing system, or a computer program product. Therefore, variousfunctionalities may be embodied in whole or in part in software,firmware and/or hardware or hardware equivalents such as integratedcircuits, field programmable gate arrays (FPGA), and the like.Particular data structures may be used to more effectively implement oneor more aspects described herein, and such data structures arecontemplated within the scope of computer executable instructions andcomputer-usable data described herein.

With further reference to FIG. 2, one or more aspects described hereinmay be implemented in a remote-access environment. FIG. 2 depicts anexample system architecture including a generic computing device 201 inan illustrative computing environment 200 that may be used according toone or more illustrative aspects described herein. Generic computingdevice 201 may be used as a server 206 a in a single-server ormulti-server desktop virtualization system (e.g., a remote access orcloud system) configured to provide virtual machines for client accessdevices. The generic computing device 201 may have a processor 203 forcontrolling overall operation of the server and its associatedcomponents, including RAM 205, ROM 207, I/O module 209, and memory 215.

I/O module 209 may include a mouse, keypad, touch screen, scanner,optical reader, and/or stylus (or other input device(s)) through which auser of generic computing device 201 may provide input, and may alsoinclude one or more of a speaker for providing audio output and a videodisplay device for providing textual, audiovisual, and/or graphicaloutput. Software may be stored within memory 215 and/or other storage toprovide instructions to processor 203 for configuring generic computingdevice 201 into a special purpose computing device in order to performvarious functions as described herein. For example, memory 215 may storesoftware used by the computing device 201, such as an operating system217, application programs 219, and an associated database 221.

Computing device 201 may operate in a networked environment supportingconnections to one or more remote computers, such as terminals 240 (alsoreferred to as client devices). The terminals 240 may be personalcomputers, mobile devices, laptop computers, tablets, or servers thatinclude many or all of the elements described above with respect to thegeneric computing device 103 or 201. The network connections depicted inFIG. 2 include a local area network (LAN) 225 and a wide area network(WAN) 229, but may also include other networks. When used in a LANnetworking environment, computing device 201 may be connected to the LAN225 through a network interface or adapter 223. When used in a WANnetworking environment, computing device 201 may include a modem 227 orother wide area network interface for establishing communications overthe WAN 229, such as computer network 230 (e.g., the Internet). It willbe appreciated that the network connections shown are illustrative andother means of establishing a communications link between the computersmay be used. Computing device 201 and/or terminals 240 may also bemobile terminals (e.g., mobile phones, smartphones, personal digitalassistants (PDAs), notebooks, etc.) including various other components,such as a battery, speaker, and antennas (not shown).

Aspects described herein may also be operational with numerous othergeneral purpose or special purpose computing system environments orconfigurations. Examples of other computing systems, environments,and/or configurations that may be suitable for use with aspectsdescribed herein include, but are not limited to, personal computers,server computers, hand-held or laptop devices, multiprocessor systems,microprocessor-based systems, set top boxes, programmable consumerelectronics, network personal computers (PCs), minicomputers, mainframecomputers, distributed computing environments that include any of theabove systems or devices, and the like.

As shown in FIG. 2, one or more client devices 240 may be incommunication with one or more servers 206 a-206 n (generally referredto herein as “server(s) 206”). In one embodiment, the computingenvironment 200 may include a network appliance installed between theserver(s) 206 and client machine(s) 240. The network appliance maymanage client/server connections, and in some cases can load balanceclient connections amongst a plurality of backend servers 206.

The client machine(s) 240 may in some embodiments be referred to as asingle client machine 240 or a single group of client machines 240,while server(s) 206 may be referred to as a single server 206 or asingle group of servers 206. In one embodiment a single client machine240 communicates with more than one server 206, while in anotherembodiment a single server 206 communicates with more than one clientmachine 240. In yet another embodiment, a single client machine 240communicates with a single server 206.

A client machine 240 can, in some embodiments, be referenced by any oneof the following non-exhaustive terms: client machine(s); client(s);client computer(s); client device(s); client computing device(s); localmachine; remote machine; client node(s); endpoint(s); or endpointnode(s). The server 206, in some embodiments, may be referenced by anyone of the following non-exhaustive terms: server(s), local machine;remote machine; server farm(s), or host computing device(s).

In one embodiment, the client machine 240 may be a virtual machine. Thevirtual machine may be any virtual machine, while in some embodimentsthe virtual machine may be any virtual machine managed by a Type 1 orType 2 hypervisor, for example, a hypervisor developed by CitrixSystems, IBM, VMware, or any other hypervisor. In some aspects, thevirtual machine may be managed by a hypervisor, while in aspects thevirtual machine may be managed by a hypervisor executing on a server 206or a hypervisor executing on a client 240.

Some embodiments include a client device 240 that displays applicationoutput generated by an application remotely executing on a server 206 orother remotely located machine. In these embodiments, the client device240 may execute a virtual machine receiver program or application todisplay the output in an application window, a browser, or other outputwindow. In one example, the application is a desktop, while in otherexamples the application is an application that generates or presents adesktop. A desktop may include a graphical shell providing a userinterface for an instance of an operating system in which local and/orremote applications can be integrated. Applications, as used herein, areprograms that execute after an instance of an operating system (and,optionally, also the desktop) has been loaded.

The server 206, in some embodiments, uses a remote presentation protocolor other program to send data to a thin-client or remote-displayapplication executing on the client to present display output generatedby an application executing on the server 206. The thin-client orremote-display protocol can be any one of the following non-exhaustivelist of protocols: the Independent Computing Architecture (ICA) protocoldeveloped by Citrix Systems, Inc. of Ft. Lauderdale, Fla.; or the RemoteDesktop Protocol (RDP) manufactured by the Microsoft Corporation ofRedmond, Wash.

A remote computing environment may include more than one server 206a-206 n such that the servers 206 a-206 n are logically grouped togetherinto a server farm 206, for example, in a cloud computing environment.The server farm 206 may include servers 206 that are geographicallydispersed while and logically grouped together, or servers 206 that arelocated proximate to each other while logically grouped together.Geographically dispersed servers 206 a-206 n within a server farm 206can, in some embodiments, communicate using a WAN (wide), MAN(metropolitan), or LAN (local), where different geographic regions canbe characterized as: different continents; different regions of acontinent; different countries; different states; different cities;different campuses; different rooms; or any combination of the precedinggeographical locations. In some embodiments the server farm 206 may beadministered as a single entity, while in other embodiments the serverfarm 206 can include multiple server farms.

In some embodiments, a server farm may include servers 206 that executea substantially similar type of operating system platform (e.g.,WINDOWS, UNIX, LINUX, iOS, ANDROID, SYMBIAN, etc.) In other embodiments,server farm 206 may include a first group of one or more servers thatexecute a first type of operating system platform, and a second group ofone or more servers that execute a second type of operating systemplatform.

Server 206 may be configured as any type of server, as needed, e.g., afile server, an application server, a web server, a proxy server, anappliance, a network appliance, a gateway, an application gateway, agateway server, a virtualization server, a deployment server, a SecureSockets Layer (SSL) VPN server, a firewall, a web server, an applicationserver or as a master application server, a server executing an activedirectory, or a server executing an application acceleration programthat provides firewall functionality, application functionality, or loadbalancing functionality. Other server types may also be used.

Some embodiments include a first server 106 a that receives requestsfrom a client machine 240, forwards the request to a second server 106b, and responds to the request generated by the client machine 240 witha response from the second server 106 b. First server 106 a may acquirean enumeration of applications available to the client machine 240 aswell as address information associated with an application server 206hosting an application identified within the enumeration ofapplications. First server 106 a can then present a response to theclient's request using a web interface, and communicate directly withthe client 240 to provide the client 240 with access to an identifiedapplication. One or more clients 240 and/or one or more servers 206 maytransmit data over network 230, e.g., network 101.

FIG. 2 shows a high-level architecture of an illustrative desktopvirtualization system. As shown, the desktop virtualization system maybe single-server or multi-server system, or cloud system, including atleast one virtualization server 206 configured to provide virtualdesktops and/or virtual applications to one or more client accessdevices 240. As used herein, a desktop refers to a graphical environmentor space in which one or more applications may be hosted and/orexecuted. A desktop may include a graphical shell providing a userinterface for an instance of an operating system in which local and/orremote applications can be integrated. Applications may include programsthat execute after an instance of an operating system (and, optionally,also the desktop) has been loaded. Each instance of the operating systemmay be physical (e.g., one operating system per device) or virtual(e.g., many instances of an OS running on a single device). Eachapplication may be executed on a local device, or executed on a remotelylocated device (e.g., remoted).

Generating a Document Object Model

FIG. 3 illustrates a method 300 of data flow for generating a DocumentObject Model (DOM) and loading external content according to one or moreillustrative aspects described herein. When displaying an HTML web page,a web browser will generate a DOM using a method similar to method 300.

At step 310, a web page or a selection of a web page to load isreceived. For example, a user or a program may enter a URL of a web pageinto a web browser. At step 320, a “shouldStartLoading” or platformequivalent callback may be issued to verify that the page load shouldbegin. If a verification that the page load should begin is received,the method 300 may proceed to step 330.

At step 330, a DOM for the page received at step 310 may be generated,e.g., by the browser engine. At step 340, pending network requests forexternal content may be generated based on the DOM. The browser may scanthe DOM to determine external content linked to in the page, such asimages or scripts, and generate a list of pending network requests forthe external content.

At step 350, the pending network requests may be issued. By issuing thepending network requests, the external content may be retrieved. Duringexecution, this step may consume a relatively large portion of the timeand resources used by method 300. For example, step 350 may take longerto perform than the other steps in method 300. At step 360, a“didFinishLoad” callback may be issued, indicating that the web page hasbeen loaded.

Typically, after the “didFinishLoad” callback, the DOM will be availablefor retrieval by an external application. For example, the DOM may beretrieved using a browser developer tools feature of a web browser.

Generating a Document Object Model without Loading External Content

Aspects described herein may be used to render any content that benefitsfrom an HTML document object model (DOM) being pre-rendered. Whileaspects described herein are discussed in the context of an emailclient, the features herein may also be used with other types of contentthat rely on an HTML DOM for rendering. This may include, withoutlimitation, any application that supports HTML format documents to whichthe application may want to apply custom styles. For example, anapplication that is used to show notes taken in another application maywant to apply its own styles to the notes that it receives in HTMLformat, and may therefore benefit from aspects described herein.

An email client may use one or more web browsers to render and/ordisplay HTML content in emails. The email client may apply a set ofuniform styles to the HTML before displaying the HTML. The email clientmay prevent JavaScript in the email from executing, including JavaScriptcontained in Cascading Style Sheets (CSS). For example, the email clientmay prevent JavaScript from executing for security reasons.Additionally, the email client may remove content from HTML in an email.To apply styles, prevent JavaScript from executing, or remove content,the email client may interpret, or parse, the HTML in the email.

Interpreting HTML documents using regular expressions may be difficultdue to variations in HTML tags. FIG. 6 illustrates examples ofvariations in HTML tags. HTML is an irregular language, and thus may bedifficult to parse consistently using regular expressions. A DOMcorresponding to an HTML document may be more consistent, or regular,than the original HTML document.

As described in FIG. 3, a DOM may be generated by a web browser loadingan HTML document. Although a DOM may be constructed prior to the browserretrieving external content, typically, the DOM is only available afterthe external content has been retrieved. In certain instances, it may bedesirable to retrieve the DOM prior to or without the browser issuingthe list of pending network requests for external content at step 350.Issuing the list of pending network requests at step 350 may be timeconsuming. For example, loading external resources while generating aDOM may cause delays. For certain applications, it may be preferable togenerate a DOM without performing the actions described at step 350. Byperforming method 300 without step 350, a DOM may be generated withoutissuing pending network requests.

In certain implementations, email clients may display an HTML emailtwice. First, the web page generated by a browser creating the DOM isdisplayed, and then, a web page generated using the DOM and customstyles or scripts is displayed. This may result in a flickering, orchanging, display. Displaying an HTML email once rather than twiceresults in a user interface without flickering or changing emails,thereby providing an improved user experience.

FIG. 4 illustrates a method and data flow 400 for displaying an HTMLemail according to one or more illustrative aspects described herein. Atstep 410, an HTML email may be received, selected, or opened. Forexample, a user may select an HTML email to view at step 410. Althoughstep 410 describes an HTML email, any HTML document may be received atstep 410. Additionally, documents in another markup language may bereceived at step 410. For example, an extensible hypertext markuplanguage (XHTML) document may be received at step 410. Other markuplanguages for which a DOM or similar construct can be generated may alsobe used.

At step 420, script may be injected, or inserted, in the HTML emailreceived at step 410. The script may prevent a browser loading the HTMLemail from downloading external content. For example, the script maycause the browser to stop any pending network requests. In oneimplementation, the script may be a JavaScript DOMContentLoaded eventhandler that causes the browser to call a “window.stop( )” function.FIG. 7, described below, illustrates an example of a script that may beinjected at step 420.

At step 430, the HTML email with the injected script may be loaded in afirst browser. An indication that parsing is underway may be issued. Forexample, a value may be returned indicating that parsing is underway.The first browser may then generate a DOM corresponding to the HTMLemail. For example, portions of method 300 may be used to generate theDOM. FIG. 6, described below, illustrates examples of disparate HTMLdocuments and a corresponding common DOM that is created based on each.

The first browser may be an off-screen browser, which may be referred toas a headless HTML parser. For example, the first browser might not bedisplayed on a screen, have a user interface, or be viewable by a user.The first browser may be a background application. The injected scriptmay cause the browser to cancel any network requests for externalcontent that are issued while generating the DOM.

FIG. 5 illustrates a method and data flow 500 for creating a DOMaccording to one or more illustrative aspects described herein. In oneimplementation, method 500 may be executed at step 430 of method 400. Inthis implementation, method 400 and method 500 may executeasynchronously, or portions of method 400 and portions of method 500 mayexecute asynchronously.

At step 510, the first browser begins loading an HTML document withJavaScript. In one implementation, the JavaScript may respond to aDOMContentLoaded event. An example of JavaScript that may be containedin an HTML document is described below in FIG. 7. Although step 510describes an HTML document with JavaScript, other types of script may beused to perform method 500.

At step 520, the first browser may begin generating a DOM correspondingto the HTML document. When the first browser is generating the DOM, thebrowser may fire, or execute, the DOMContentLoaded event. The event maybe fired during the DOM rendering process when the DOM has beenassembled into an object model and before network requests have beenmade. For example, if the first browser is generating a DOM using method300, the DOMContentLoaded event may be fired between steps 340 and 350.

At step 530, the DOMContentLoaded event causes a function to be calledthat stops the first browser from loading external content. For example,a “windows.stop( )” function may be called to stop further processing ofthe HTML by the first browser while leaving the DOM intact. In thisexample, when the “windows.stop( )” function is called, pending networkrequests may be canceled and the DOM tree may be available.

At step 540, the first browser may indicate that the DOM is available.For example, the first browser may invoke an error delegate with acancelled error code. FIG. 8, described below, illustrates an example ofa script that may cause an error code to be issued when the DOM isavailable.

Returning to method 400, at step 440, a notification may be receivedthat the HTML email has been loaded in the first browser. Thenotification may indicate that the DOM generated at step 430 isavailable for retrieval. For example, if an email client loads an HTMLemail message in the first browser, the first browser may transmit amessage to the email client indicating that the DOM is available. In oneimplementation, a completion block received through an ApplicationProgram Interface (API) may be used to indicate that the DOM isavailable.

At step 450, the DOM generated by the first browser may be used toextract a portion of the HTML in the HTML email, or a portion of theDOM. For example, HTML that is between the “body” tags in the DOM may beextracted. CSS or JavaScript content contained within the HTML emailreceived at step 410 might not be included in the extracted HTML. Forexample, if CSS code is included in a header of the HTML email receivedat step 410, the CSS code might not be included in the extracted HTML.The extracted content may be style-neutral insofar as it may comprisetext or other content without any formatting.

At step 460, custom parsing logic may be applied to the HTML extractedat step 450. For example, a CSS stylesheet or other predefinedformatting rules may be applied to the HTML extracted at step 450. Anemail client may use custom CSS to display emails with consistentformatting. By removing CSS included in an HTML email at step 450, theemail client may be able to apply the custom CSS to the HTML email.After the custom parsing and processing is completed, a completioncallback may be invoked.

At step 470, a second browser may display the portion of the HTMLextracted at step 450 with the custom parsing logic applied at step 460.All or portions of the second browser may be displayed. For example, anemail client may use the second browser to display the HTML that isgenerated at step 460. In one implementation, the first browser and thesecond browser may be the same browser, or multiple instances of abrowser.

Portions of method 400 may be implemented using an API. For example, anAPI may to receive an HTML document or email, receive logic to apply tothe HTML document, such as CSS, and receive a completion block to invokeafter parsing of the HTML document is completed.

FIG. 6 depicts examples of HTML and a corresponding DOM according to oneor more illustrative aspects described herein. HTML examples 610, 620,and 630 are examples of HTML that may be used to form a webpage with thetext “hello.” HTML 610 includes both opening and closing body tags. HTML620 includes a closing body tag without an opening body tag. HTML 630includes neither an opening nor a closing body tag. Although HTMLexamples 610, 620, and 630 all include different tags, a DOM 640corresponding to examples 610, 620, and 630 is the same.

As described above, interpreting HTML documents using regularexpressions may be difficult due to variations in HTML tags. In FIG. 6,the body of the HTML examples 610, 620, and 630 comprises the text“hello,” but the text is surrounded by different tags in the examples.Regardless of whether or not tags are missing in 610, 620, or 630, theDOM 640 comprises the text “hello” between an opening and closing bodytag. Parsing a DOM, or applying logic to the DOM, may result in moreconsistency than directly parsing HTML.

FIG. 7 illustrates an example of a script that may stop pending networkrequests according to one or more illustrative aspects described herein.The script in FIG. 7 may be inserted into an HTML document to prevent abrowser loading the HTML document from requesting external content. Inthe code in FIG. 7, a “window.stop( )” command may be issued when a“DOMContentLoaded” event is detected. The “window.stop( )” command maycause the browser to stop or cancel any pending network requests relatedto the HTML document.

FIG. 8 illustrates an example of a script that may issue a detectableerror code according to one or more illustrative aspects describedherein. The script illustrated in FIG. 8 may be used to detect that DOMcontent is available on iOS. The script may cause an error code to beissued in response to a load cancellation. After receiving the errorcode, further requests may be issued to parse the DOM. For example,JavaScript requests may be used to parse the DOM. Other platforms, suchas Android, may provide a different interface for detecting a browserload completion event.

Although the subject matter has been described in language specific tostructural features and/or methodological acts, it is to be understoodthat the subject matter defined in the appended claims is notnecessarily limited to the specific features or acts described above.Rather, the specific features and acts described above are described asexample implementations of the following claims.

What is claimed is:
 1. A method, comprising: adding a script to areceived email, wherein the script is configured to prevent a webbrowser from retrieving external content linked within the email;loading the email including the added script, using the web browser; inresponse to receiving, from the web browser, an indication that parsingof the email is in progress, generating, using the web browser, adocument object model (DOM) corresponding to the email; canceling, bythe script and during generation of the DOM corresponding to the email,one or more pending network requests to retrieve the external contentlinked within the email; and rendering the email from the DOM, whereinrendering the email from the DOM comprises extracting content from abody portion of the DOM and rendering the email from the extractedcontent.
 2. The method of claim 1, wherein the email comprises HyperText Markup Language (HTML).
 3. The method of claim 1, wherein thescript comprises JavaScript.
 4. The method of claim 1, wherein thescript configured to prevent the web browser from retrieving externalcontent comprises a script configured to prevent the web browser fromretrieving external images.
 5. The method of claim 1, wherein the scriptconfigured to prevent the web browser from retrieving external contentcomprises a script configured to cause the web browser to cancel the oneor more pending network requests.
 6. The method of claim 1, wherein theweb browser is an off screen web browser.
 7. The method of claim 1,wherein the script comprises a JavaScript event listener or a JavaScriptevent handler.
 8. The method of claim 1, wherein rendering the emailfrom the DOM further comprises generating an HTML document based on aportion of the DOM.
 9. The method of claim 8, further comprising:receiving a style sheet; and applying the style sheet to the HTMLdocument.
 10. The method of claim 9, further comprising: receiving acompletion block; and invoking the completion block after applying thestyle sheet to the HTML document.
 11. The method of claim 10, whereinreceiving the style sheet and the completion block comprises receivingthe style sheet and the completion block using an application programinterface (API).
 12. One or more non-transitory, computer-readablestorage media storing computer readable instructions that, whenexecuted, cause a system to perform: adding a script to a receivedemail, wherein the script is configured to prevent a web browser fromretrieving external content linked within the email; loading the emailincluding the added script, using the web browser; in response toreceiving, from the web browser, an indication that parsing of the emailis in progress, generating, using the web browser, a document objectmodel (DOM) corresponding to the email; canceling, by the script andduring generation of the DOM corresponding to the email, one or morepending network requests to retrieve the external content linked withinthe email; and rendering the email from the DOM, wherein rendering theemail from the DOM comprises extracting content from a body portion ofthe DOM and rendering the email from the extracted content.
 13. Thecomputer-readable storage media of claim 12, wherein the email comprisesHyper Text Markup Language (HTML) and wherein the script comprisesJavaScript.
 14. The computer-readable storage media of claim 12, whereinthe script configured to prevent the web browser from retrievingexternal content comprises a script configured to prevent the webbrowser from retrieving external images and to cause the web browser tocancel the one or more pending network requests.
 15. Thecomputer-readable storage media of claim 12, wherein the web browser isan off screen web browser.
 16. The computer-readable storage media ofclaim 12, wherein the script comprises a JavaScript event listener or aJavaScript event handler.
 17. The computer-readable storage media ofclaim 12, wherein rendering the email from the DOM further comprisesgenerating an HTML document based on a portion of the DOM.
 18. Thecomputer-readable storage media of claim 17, said instructions furthercausing the system to perform: receiving, via an application programinterface (API), a style sheet; applying the style sheet to the HTMLdocument; receiving, via the API, a completion block; and invoking thecompletion block after applying the style sheet to the HTML document.